** For "Who Holds Sovereign Debt and Why It Matters" by Fang, Hardy, and Lewis
clear all
set more off
cd "~/Dropbox/Sovereign Bond Project/Replication_Package_submission_RFS"

global All_List Foreign DomCB DomBK DomNB
global UST_List MMFs HH InsurPens OthFin OthNonFin
global UKG_List FundsandOthFin InsurPens NonFin


************************************************************************
****                         UST Analysis                           ****
************************************************************************
use "Data/UST_UKG_Data/UST_Data.dta", clear

tsset date
foreach x in Total $All_List $UST_List {
	gen d_`x' = d.`x'
	gen d_`x'_tot = d.`x'/l.Total
}
keep if date>=tq(1995q1) & date<=tq(2020q4)

preserve
gen MMF_HH_Share = (MMFs + HH) / DomNB 
collapse (mean) MMF_HH_Share // 26%
scalar MMF_HH_Share = MMF_HH_Share
restore

label var d_Total_tot "UST"

foreach v in $All_List {
reg d_`v'_tot d_Total_tot
}
scalar coef_DomNB = _b[d_Total_tot]

foreach v in $UST_List {
reg d_`v'_tot d_Total_tot
scalar share_`v' = _b[d_Total_tot] / coef_DomNB // share of DomNB marginal
}


************************************************************************
****                         Gilt Analysis                          ****
************************************************************************
use "Data/UST_UKG_Data/UKG_Data.dta", clear

tsset date
foreach x in Total $All_List $UKG_List {
	gen d_`x' = d.`x'
	gen d_`x'_tot = d.`x'/l.Total
}
keep if date>=tq(1995q1) & date<=tq(2020q4)

label var d_Total_tot "UKG"

foreach v in $All_List {
reg d_`v'_tot d_Total_tot
}
scalar coef_DomNB = _b[d_Total_tot]

foreach v in $UKG_List {
reg d_`v'_tot d_Total_tot
scalar share_`v' = _b[d_Total_tot] / coef_DomNB // share of DomNB marginal
}







